package cn.leetcode;

public class Code98 {

    private long num = Long.MIN_VALUE;

    public boolean isValidBST(TreeNode root) {
        return fun(root);
    }


    public boolean fun(TreeNode root){
        if(root == null){
            return true;
        }
        boolean fun1 = fun(root.left);
        if(!fun1){
            return false;
        }
        if(num >= root.val){
            return false;
        }
        num = root.val;
        return fun(root.right);
    }



}
